import jobApi from "@/api/declaration/jobApi"
import httpRequest from "@/config/axios/httpRequest"
import { JobModel } from "@/models/jobs/JobModel"




// 任务列表
export const getJobPage = (params: PageParam) => {
  return httpRequest.get(jobApi.GetJobPage,{
    params
  })
}

// 任务详情
export const getJob = (id: number) => {
  return httpRequest.get(jobApi.GetJob,{
    params:{id}
  })
}

// 新增任务
export const createJob = (data: JobModel) => {
  return httpRequest.post(jobApi.CreateJob,data)
}

// 修改定时任务调度
export const updateJob = (data: JobModel) => {
  return httpRequest.put(jobApi.UpdateJob,data)
}

// 删除定时任务调度
export const deleteJob = (id: number) => {
  return httpRequest.delete(jobApi.DeleteJob,{params:{id}})
}

// 导出定时任务调度
export const exportJob = (params) => {
  return httpRequest.download(jobApi.ExportJob, params)
}

// 任务状态修改
export const updateJobStatus = (id: number, status: number) => {
  const params = {
    id,
    status
  }
  return httpRequest.put(jobApi.UpdateJobStatus, params)
}

// 定时任务立即执行一次
export const runJob = (id: number) => {
  return httpRequest.put(jobApi.RunJob, { id })
}

// 获得定时任务的下 n 次执行时间
export const getJobNextTimes = (id: number) => {
  return httpRequest.get(jobApi.GetJobNextTimes, { params: { id } })
}
